home *** CD-ROM | disk | FTP | other *** search
- ///////////////////////////////////////////////////////////////////////////////
- // $Id: m68000.hxx,v 1.5 1995/06/30 00:08:20 bmott Exp $
- ///////////////////////////////////////////////////////////////////////////////
- // m68000.hxx
- //
- // Motorola 68000 microprocessor class
- //
- // Sim68000 "Motorola 68000 Simulator"
- // Copyright (c) 1993
- // By: Bradford W. Mott
- // October 31,1993
- //
- ///////////////////////////////////////////////////////////////////////////////
- // $Log: m68000.hxx,v $
- // Revision 1.5 1995/06/30 00:08:20 bmott
- // Modified declaration for ServiceInterrupts()
- //
- // Revision 1.4 1995/01/13 00:34:01 bmott
- // Changed the in_register argument from the ComputeEffectiveAddress
- // member function
- //
- // Revision 1.3 1994/09/22 00:12:26 bmott
- // Add BREAK instruction method
- //
- // Revision 1.2 1994/08/22 07:31:49 bmott
- // Removed const from the register information structure
- //
- // Revision 1.1 1994/02/18 20:04:40 bmott
- // Initial revision
- //
- ///////////////////////////////////////////////////////////////////////////////
-
- #ifndef M68000_HXX
- #define M68000_HXX
-
- #include <iostream.h>
- #include "BasicCPU.hxx"
- #include "BasicDevice.hxx"
-
- // Instruction Size Constants
- #define BYTE 0
- #define WORD 1
- #define LONG 2
-
- // Set Condition Code operation types
- #define ADDITION 0
- #define SUBTRACTION 1
- #define OTHER 2
-
- class m68000;
-
- // Register information structure
- struct RegisterData {
- char* name;
- unsigned long mask;
- char* description;
- };
-
- // Pointer to an instruction execution routine
- typedef int (m68000::*ExecutionPointer)(int, String&, int);
-
- // DecodeEntry structure for the Decode Table
- struct DecodeEntry {
- unsigned int mask;
- unsigned int signature;
- ExecutionPointer execute;
- };
-
-
-
- class m68000 : public BasicCPU {
- private:
- // Number of registers in the cpu
- const int number_of_registers;
-
- // Array of static information for each register
- static RegisterData register_data[];
-
- // Pointer to an array of values for each register
- unsigned long *register_value;
-
- // Indices into the register arrays (Note: D0-D7-A0-A7' must be sequential)
- const int D0_INDEX;
- const int A0_INDEX;
- const int USP_INDEX;
- const int SSP_INDEX;
- const int PC_INDEX;
- const int SR_INDEX;
-
- // Status Register masks
- const unsigned long C_FLAG; // Carry
- const unsigned long V_FLAG; // Overflow
- const unsigned long Z_FLAG; // Zero
- const unsigned long N_FLAG; // Negative
- const unsigned long X_FLAG; // Extend
- const unsigned long I0_FLAG; // Interrupt Mask Level
- const unsigned long I1_FLAG; // Interrupt Mask Level
- const unsigned long I2_FLAG; // Interrupt Mask Level
- const unsigned long S_FLAG; // Supervisory
- const unsigned long T_FLAG; // Trace Mode
-
- // Execution Return Constants
- const int EXECUTE_OK;
- const int EXECUTE_PRIVILEGED_OK;
- const int EXECUTE_BUS_ERROR;
- const int EXECUTE_ADDRESS_ERROR;
- const int EXECUTE_ILLEGAL_INSTRUCTION;
-
- // Processor state (NORMAL_STATE, HALT_STATE, or STOP_STATE, BREAK_STATE)
- unsigned int processor_state;
-
- // Procesor state constants
- const unsigned int NORMAL_STATE;
- const unsigned int HALT_STATE;
- const unsigned int STOP_STATE;
- const unsigned int BREAK_STATE;
-
-
- static DecodeEntry decode_table[];
- static ExecutionPointer *decode_cache_table;
-
- // Decode the given instruction
- ExecutionPointer DecodeInstruction(int opcode);
-
- // Routines to simulate the execution of the instruction
- int ExecuteABCD(int opcode, String& description, int trace);
- int ExecuteADD(int opcode, String& description, int trace);
- int ExecuteADDA(int opcode, String& description, int trace);
- int ExecuteADDI(int opcode, String& description, int trace);
- int ExecuteADDQ(int opcode, String& description, int trace);
- int ExecuteADDX(int opcode, String& description, int trace);
- int ExecuteAND(int opcode, String& description, int trace);
- int ExecuteANDI(int opcode, String& description, int trace);
- int ExecuteANDItoCCR(int opcode, String& description, int trace);
- int ExecuteANDItoSR(int opcode, String& description, int trace);
- int ExecuteASL(int opcode, String& description, int trace);
- int ExecuteASR(int opcode, String& description, int trace);
- int ExecuteBRA(int opcode, String& description, int trace);
- int ExecuteBREAK(int opcode, String& description, int trace);
- int ExecuteBSR(int opcode, String& description, int trace);
- int ExecuteBcc(int opcode, String& description, int trace);
- int ExecuteBit(int opcode, String& description, int trace);
- int ExecuteCHK(int opcode, String& description, int trace);
- int ExecuteCLR(int opcode, String& description, int trace);
- int ExecuteCMP(int opcode, String& description, int trace);
- int ExecuteCMPA(int opcode, String& description, int trace);
- int ExecuteCMPI(int opcode, String& description, int trace);
- int ExecuteCMPM(int opcode, String& description, int trace);
- int ExecuteDBcc(int opcode, String& description, int trace);
- int ExecuteDIVS(int opcode, String& description, int trace);
- int ExecuteDIVU(int opcode, String& description, int trace);
- int ExecuteEOR(int opcode, String& description, int trace);
- int ExecuteEORI(int opcode, String& description, int trace);
- int ExecuteEORItoCCR(int opcode, String& description, int trace);
- int ExecuteEORItoSR(int opcode, String& description, int trace);
- int ExecuteEXG(int opcode, String& description, int trace);
- int ExecuteEXT(int opcode, String& description, int trace);
- int ExecuteILLEGAL(int opcode, String& description, int trace);
- int ExecuteJMP(int opcode, String& description, int trace);
- int ExecuteJSR(int opcode, String& description, int trace);
- int ExecuteLEA(int opcode, String& description, int trace);
- int ExecuteLINK(int opcode, String& description, int trace);
- int ExecuteLSL(int opcode, String& description, int trace);
- int ExecuteLSR(int opcode, String& description, int trace);
- int ExecuteMOVE(int opcode, String& description, int trace);
- int ExecuteMOVEA(int opcode, String& description, int trace);
- int ExecuteMOVEM(int opcode, String& description, int trace);
- int ExecuteMOVEP(int opcode, String& description, int trace);
- int ExecuteMOVEQ(int opcode, String& description, int trace);
- int ExecuteMOVEUSP(int opcode, String& description, int trace);
- int ExecuteMOVEfromSR(int opcode, String& description, int trace);
- int ExecuteMOVEtoCCR(int opcode, String& description, int trace);
- int ExecuteMOVEtoSR(int opcode, String& description, int trace);
- int ExecuteMULS(int opcode, String& description, int trace);
- int ExecuteMULU(int opcode, String& description, int trace);
- int ExecuteNBCD(int opcode, String& description, int trace);
- int ExecuteNEG(int opcode, String& description, int trace);
- int ExecuteNEGX(int opcode, String& description, int trace);
- int ExecuteNOP(int opcode, String& description, int trace);
- int ExecuteNOT(int opcode, String& description, int trace);
- int ExecuteOR(int opcode, String& description, int trace);
- int ExecuteORI(int opcode, String& description, int trace);
- int ExecuteORItoCCR(int opcode, String& description, int trace);
- int ExecuteORItoSR(int opcode, String& description, int trace);
- int ExecutePEA(int opcode, String& description, int trace);
- int ExecuteRESET(int opcode, String& description, int trace);
- int ExecuteROL(int opcode, String& description, int trace);
- int ExecuteROR(int opcode, String& description, int trace);
- int ExecuteROXL(int opcode, String& description, int trace);
- int ExecuteROXR(int opcode, String& description, int trace);
- int ExecuteRTE(int opcode, String& description, int trace);
- int ExecuteRTR(int opcode, String& description, int trace);
- int ExecuteRTS(int opcode, String& description, int trace);
- int ExecuteSBCD(int opcode, String& description, int trace);
- int ExecuteSTOP(int opcode, String& description, int trace);
- int ExecuteSUB(int opcode, String& description, int trace);
- int ExecuteSUBA(int opcode, String& description, int trace);
- int ExecuteSUBI(int opcode, String& description, int trace);
- int ExecuteSUBQ(int opcode, String& description, int trace);
- int ExecuteSUBX(int opcode, String& description, int trace);
- int ExecuteSWAP(int opcode, String& description, int trace);
- int ExecuteScc(int opcode, String& description, int trace);
- int ExecuteTAS(int opcode, String& description, int trace);
- int ExecuteTRAP(int opcode, String& description, int trace);
- int ExecuteTRAPV(int opcode, String& description, int trace);
- int ExecuteTST(int opcode, String& description, int trace);
- int ExecuteUNLK(int opcode, String& description, int trace);
- int ExecuteInvalid(int opcode, String& description, int trace);
-
- int ExecuteBusError(int opcode, String& description, int trace);
- int ExecuteAddressError(int opcode, String& description, int trace);
-
- // Helpful routines for the 'Execute' instruction routines
- int ComputeEffectiveAddress(unsigned long& address,
- int& in_register,
- String &description, int mode_register,
- int size, int trace);
- int Peek(unsigned long address, unsigned int& value, int size);
- int Poke(unsigned long address, unsigned int value, int size);
- unsigned int SignExtend(unsigned int value, int size);
- void SetConditionCodes(unsigned int src, unsigned int dest,
- unsigned int result, int size,
- int operation, int mask);
- void ClearConditionCodes(int mask);
- int CheckConditionCodes(int code, String& mnemonic, int trace);
- void SetRegister(int register_number, unsigned int value, int size);
- int ProcessException(int vector);
-
- long my_interrupt;
- BasicDevice* my_device;
-
- public:
- m68000(AddressSpace*); // The constructor
- virtual ~m68000(); // The destructor
-
- // Execute a single instruction
- const char* ExecuteInstruction(String& trace_record, int trace_flag);
-
- // Service pending interrupts, set serviceFlag to true iff we
- // are had to service an interrupt
- int ServiceInterrupts(int& serviceFlag);
-
- // Handle an interrupt request from a device
- void InterruptRequest(BasicDevice* device, int level);
-
- // Preform a system reset
- void Reset();
-
- // Return the name of the program counter register
- char* const NameOfProgramCounter()
- { return ("PC"); }
-
- // Return the value of the program counter register
- unsigned long ValueOfProgramCounter();
-
- // Set the named register to the given value
- void SetRegister(String name, String hex_value);
-
- // Not keeping any statistics
- void ClearStatistics()
- {}
-
- void BuildRegisterInformationList(RegisterInformationList*);
-
- void BuildStatisticalInformationList(StatisticalInformationList*);
- };
-
- #endif
-